<?php
class admin_model_session extends admin_model_base  {
	public function __construct(){
		parent::__construct();
		$this->table = '_sessions';
	}
	
	public function select($sid, $fields='*'){
		$sql = "select $fields from ".$this->table." where sid=&sid";
		$params = array('sid'=>$sid);
		return $this->admin_db->fetchRow($sql, $params);
	}
	
	public function write($sid, $uid){
		$sql = "insert ignore into ".$this->table." values(&sid, &uid)";
		$params = array('sid'=>$sid, 'uid'=>$uid);
		return $this->admin_db->query($sql, $params);
	}
	
	public function remove_sid($sid){
		$sql = "delete from ".$this->table." where sid=&sid";
		$params = array('sid'=>$sid);
		return $this->admin_db->query($sql, $params);
	}
	
	public function remove_uid($uid){
		$sql = "delete from ".$this->table." where uid=&uid";
		$params = array('uid'=>$uid);
		return $this->admin_db->query($sql, $params);
	}
}